﻿using CompanyManageSystem.DLL;
using CompanyManageSystem.Model;
using CompanyManageSystem.Model.DTO;
using CompanyManageSystem.Service;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid.Views.BandedGrid;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CompanyManageSystem.UI.Repast
{
    public partial class Frm_StorageCollect : BaseXtraForm
    {
        public Frm_StorageCollect()
        {
            InitializeComponent();

            this.BindRowIndicator(bandedGridView1);
            this.SetGridViewStyle(bandedGridView1,false,false,false,true);
            this.GridRemoveZero(gridControl1);
        }

        /// <summary>
        /// 窗体加载完成
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Frm_StorageCollect_Load(object sender, EventArgs e)
        {

        }

        /// <summary>
        /// 查找
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_Find_Click(object sender, EventArgs e)
        {
            PSContext _db = new PSContext();
            _db.Database.CommandTimeout = 180;
            Type t = typeof(StorageCollectProcDTO);
            SqlParameter[] param = new SqlParameter[1];
            param[0] = new SqlParameter("@sYear", this.deYear.Text.Trim());
            var data = _db.Database.SqlQuery(t, "exec dbo.StorageCollectProc @sYear", param).Cast<StorageCollectProcDTO>().ToList();
            gridControl1.DataSource = data;
        }

        /// <summary>
        /// 导出
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            this.ExportToExcel(bandedGridView1);
        }
    }
}
